#ifndef _WIRELESS_H
#define _WIRELESS_H

#include "wireless_txrx.h"
#include "wireless_proc.h"
#include "wireless_cmd.h"
#include "../../os/os_thread.h"

#if WIRELESS_CON_COMB_BUF_EN
    #define WIRELESS_MIC_RX_BUFFER_SIZE     (WIRELESS_MIC_FRAME_SIZE*WIRELESS_MIC_COMB_NB)
    #define WIRELESS_MIC_TX_BUFFER_SIZE     (WIRELESS_MIC_FRAME_SIZE*WIRELESS_MIC_COMB_NB)*WIRELESS_MIC_RETRY_NB
    #define WIRELESS_SPK_RX_BUFFER_SIZE     (WIRELESS_SPK_FRAME_SIZE*WIRELESS_SPK_COMB_NB)
    #define WIRELESS_SPK_TX_BUFFER_SIZE     (WIRELESS_SPK_FRAME_SIZE*WIRELESS_SPK_COMB_NB)*WIRELESS_SPK_RETRY_NB
#else
    #define WIRELESS_MIC_RX_BUFFER_SIZE     (WIRELESS_MIC_FRAME_SIZE*WIRELESS_MIC_COMB_NB)
    #define WIRELESS_MIC_TX_BUFFER_SIZE     (WIRELESS_MIC_FRAME_SIZE*WIRELESS_MIC_COMB_NB)
    #define WIRELESS_SPK_RX_BUFFER_SIZE     (WIRELESS_SPK_FRAME_SIZE*WIRELESS_SPK_COMB_NB)
    #define WIRELESS_SPK_TX_BUFFER_SIZE     (WIRELESS_SPK_FRAME_SIZE*WIRELESS_SPK_COMB_NB)
#endif


void wireless_init(void);
void wireless_mic_kick(void);

void sbc_enc_init(u8 spr, u8 nch);
uint sbc_enc(u8 *sbcen_ibuf, u8 *sbcout_obuf, u16 samples);

void sbc_dec(u8 *ibuf, s16 *obuf, uint samples, uint index);
void dac_out_adj_phase(u16 high_samples, u16 low_samples);

void bt_get_tick1_time(uint tick_cnt);
void bt_play_sync_tick1(bool from_dac, uint8_t interval);
void bt_get_dac_fifocnt(uint tick_cnt);
void bt_play_sync_dac_fifocnt(uint32_t target, uint8_t interval);


void mic_enc_audio_input(u8 *ptr, u32 samples, int ch_mode, void *params);
void mic_enc_audio_output_callback_set(audio_callback_t callback);
void mic_enc_init(u8 sample_rate, u16 samples);
void mic_enc_reset(void);

void mic_dec_audio_input(u8 *ptr, u32 samples, int ch_mode, void *params);
void mic_dec_audio_output_callback_set(audio_callback_t callback);
void mic_dec_init(u8 sample_rate, u16 samples);
void mic_dec_reset(u8 idx);

void spk_dec_audio_input(u8 *ptr, u32 len, int ch_mode, void *params);
void spk_dec_audio_output_callback_set(audio_callback_t callback);
void spk_dec_init(u8 sample_rate, u16 samples);
void spk_enc_audio_input(u8 *ptr, u32 samples, int ch_mode, void *params);
void spk_enc_audio_output_callback_set(audio_callback_t callback);
void spk_enc_init(u8 sample_rate, u16 samples);

void wireless_adapter_init(void);
void wireless_device_init(void);
void wireless_device_exit(void);
void wireless_adapter_exit(u8 idx);
void wireless_channel_status(u8 chidx, s8 rssi, u8 bfi, u8 chstatus);

#endif //_WIRELESS_H
